home *** CD-ROM | disk | FTP | other *** search
/ Gold Medal Software 3 / Gold Medal Software - Volume 3 (Gold Medal) (1994).iso / music / 5mods_2.arj / AUTOMSG.MOD < prev    next >
Text File  |  1994-01-27  |  15KB  |  417 lines

  1.  ┌────────────────────────────────────────────────────────────────────────────┐
  2.  │  EGG2.MOD - A New Auto-Message (Version 1.1)                               │
  3.  │    Frustrated with the small auto-message in stock WWIV, I wrote this.  It │
  4.  │ lets you  write  an auto-message with  Ctrl-P color, word  wrap, unlimited │
  5.  │ lines, the  Ctrl-N/X/W  features, etc.  You  can  lock  the  auto  message │
  6.  │ (letting only the sysop write it) or  unlock it (letting anyone change it) │
  7.  │ while in the BBS, without having to recompile.                             │
  8.  │    New features in 1.1:  Now all variables are kept external, so that  you │
  9.  │ can change them without recompiling the BBS.  They are: maximum  lines per │
  10.  │ message, the security level to write  anonymous, the auto-message  colors, │
  11.  │ the auto-message lock, whether or  not  the auto-message is anonymous, and │
  12.  │ the author  of  the auto-message.  There  is  now an editor, accessed with │
  13.  │ //AEDIT from the main menu, to edit those variables.                       │
  14.  │    More stuff:  The ability to write anonymous auto-messages, configurable │
  15.  │ colors, two auto-message files are written now, one for ansi users and one │
  16.  │ for those without ansi, the choice to abort an auto-message if no  subject │
  17.  │ is given, auto-replying to the author of an auto-message.                  │
  18.  │                                                                            │
  19.  │  The Disclaimer:  I'm only  responsible for the GOOD things this mod does. │
  20.  │  Simple enough, eh? :-)  Address any comments, etc to 1@15284 (Scramblegg) │
  21.  └────────────────────────────────────────────────────────────────────────────┘
  22.  ┌────────────────────────────────────────────────────────────────────────────┐
  23.  │Upgrading from Version 1.0 -- Read this ONLY if you are upgrading from 1.0  │
  24.  │                                                                            │
  25.  │  You  will  probably just want to delete  your newam() function, and  just │
  26.  │add the new one in its place.  But be sure  to  follow the directions since │
  27.  │some stuff will need to be modified.  Do ALL of the steps except #1.        │
  28.  └────────────────────────────────────────────────────────────────────────────┘
  29.  
  30. Help: Anything in a box is code that you need to look for or change.  Just
  31. follow the instructions.
  32.  
  33. ============================================================================
  34. Step 1 - Take out old auto message (Skip if you are upgrading)
  35. ============================================================================
  36. At the beginning of MISCCMD.C, change
  37. ┌───────────────────────┐
  38. │void read_automessage()│
  39. └───────────────────────┘
  40. to
  41. ┌───────────────────────┐
  42. │/*                     │
  43. │void read_automessage()│
  44. └───────────────────────┘
  45. and then at the end of write_automessage(), where it has
  46. ┌─────────────────────────────────┐
  47. │  } while ((!done) && (!hangup));│
  48. │                                 │
  49. │}                                │
  50. └─────────────────────────────────┘
  51. change to
  52. ┌─────────────────────────────────┐
  53. │  } while ((!done) && (!hangup));│
  54. │                                 │
  55. │}*/                              │
  56. └─────────────────────────────────┘
  57.  
  58. This deletes the normal auto-message functions by putting them in comments.
  59. But, they are still available should you have problems.
  60.  
  61. ============================================================================
  62. Step 2: Add New Auto Message function (Be sure and do this step!)
  63. ============================================================================
  64. Add this to the bottom of MISCCMD.C:
  65.  
  66. /* If you're upgrading, be sure to take out the #define AMSGLINES */
  67.  
  68. void newam()
  69. {
  70.   time_t secs_now;
  71.   struct tm *mt;
  72.   char k,s[161],ro[160],fn[80],author[80],color1,color2,lock,anony;
  73.   int optoo,AMSGLINES,mailto,anonysl;
  74.   FILE *ff,*gg;
  75.  
  76.   gg=fopen("AUTOMSG.CNT","r+");
  77.   if(gg==NULL) {
  78.     nl();
  79.     prt(1,"Auto message status file not found. Creating with defaults.");
  80.     gg=fopen("AUTOMSG.CNT","w+");
  81.     fprintf(gg,"20\n255\n7\n1\n0\n0\n ");
  82.     fseek(gg,0,SEEK_SET);
  83.     nl();
  84.   }
  85.   AMSGLINES=atoi(fgets(s,80,gg));
  86.   anonysl=atoi(fgets(s,80,gg));
  87.   color1=atoi(fgets(s,80,gg));
  88.   color2=atoi(fgets(s,80,gg));
  89.   lock=atoi(fgets(s,80,gg));
  90.   anony=atoi(fgets(s,80,gg));
  91.   fgets(author,80,gg);
  92.   fclose(gg);
  93.  
  94.   for(;;) {
  95.     ro[0]=0;
  96.     nl();
  97.     npr("%c%d%s Auto-Message Menu\r\n",3,color1,syscfg.systemname);
  98.     sprintf(fn,", [%c%dL%c%d]ock/Unlock Auto-Message",3,color1,3,color2);
  99.     ansic(color2);
  100.     npr("[%c%dR%c%d]ead, [%c%dW%c%d]rite, [%c%dQ%c%d]uit, [%c%dA%c%d]uto-Reply%
  101. s : ",3,color1,3,
  102.                 color2,3,color1, 3,color2, 3,color1, 3,color2, 3,color1,3,color
  103. 2,
  104.            so() ? fn : "");
  105.     if(!so())
  106.       k=onek("RWQA");
  107.     else
  108.       k=onek("RWQAL");
  109.     switch(k) {
  110.        case 'Q': return;
  111.        case 'L':
  112.          nl();
  113.          lock = (!lock);
  114.          ansic(7);
  115.          npr("Auto-Message is now %s\r\n", lock ? "Locked" :
  116.             "Unlocked");
  117.          break;
  118.        case 'R': printfile("NEW_AUTO"); break;
  119.        case 'A':
  120.          if(anony && actsl<anonysl) {
  121.             nl();
  122.             ansic(2);
  123.             pl("This is an anonymous auto-message.  You cannot auto-reply.");
  124.             break;
  125.          }
  126.          nl();
  127.          mailto=finduser(author);
  128.          if(mailto>0)
  129.            email(mailto,0,0,0);
  130.          else
  131.           pl("Sorry, the user who wrote this auto-message cannot be found.");
  132.          break;
  133.        case 'W':
  134.          if(lock && (!so())) {
  135.             nl();
  136.             prt(7,"The auto-message has been locked by the SysOp");
  137.             break;
  138.          }
  139.          secs_now = time(NULL);
  140.          mt = localtime(&secs_now);
  141.          sprintf(fn,"%sTEMP.MSG",syscfg.gfilesdir);
  142.          ff=fopen(fn,"w");
  143.          if(ff==NULL) return;
  144.          nl();
  145.          if(actsl>=anonysl) {
  146.             outstr("Would you like this to be anonymous? ");
  147.             anony=yn();
  148.          }
  149.          fprintf(ff,"%c%dAuto-Message written by %c%d%s%c%d on %c%d%d/%d/%d%c0\
  150. n",
  151.                      3,color2, 3, color1, anony ? "ANONYMOUS" : thisuser.name,
  152.                      3,color2, 3, color1, (mt->tm_mon)+1,mt->tm_mday,
  153.                      mt->tm_year,3);
  154.          fprintf(ff,"%c%d",3,color2);
  155.          for(k=0;k<79;k++)
  156.            fputc(196, ff);
  157.          fprintf(ff,"\n");
  158.          ansic(7);
  159.          outstr("Subject: ");
  160.          ansic(0);
  161.          mpl(60);
  162.          inputl(s,60);
  163.          if(strlen(s)==0) {
  164.            prt(2,"No subject. Abort? ");
  165.            if(yn()) break;
  166.          }
  167.          fprintf(ff,"%c%dSubject:%c%d %s\n", 3,color1, 3, color2, s);
  168.          s[0]=0;
  169.          fprintf(ff,"%c%d",3,color2);
  170.          for(k=0;k<79;k++)
  171.            fputc(196, ff);
  172.          fprintf(ff,"\n");
  173.          nl();
  174.          optoo=0;
  175.          npr("Enter Auto-Message now - %s line limit. /ES saves."
  176.          " /ABT aborts. ", (AMSGLINES) ? itoa(AMSGLINES,s,10) : "No");
  177.          s[0]=0;
  178.          pl("Control-P color codes are recognized.");
  179.          outstr("[--------.---------.---------.---------.---------.---------.--
  180. -------.---------]");
  181.          for(k=0;optoo==0;) {
  182.             if(k==AMSGLINES && (AMSGLINES)) {
  183.                for(;;) {
  184.                  outstr("Save? ");
  185.                  if(yn()) optoo=1;
  186.                  outstr("Abort? ");
  187.                  if(!ny()) {
  188.                    nl();
  189.                    prt(1,"You have reached the maximum line limit -- You MUST s
  190. ave or abort!\r\n");
  191.                  }
  192.                  else optoo=2;
  193.                  if(optoo) break;
  194.               }
  195.             }
  196.             if(k==(AMSGLINES-1) && (AMSGLINES))
  197.                prt(0,"This is your 6last0 line!\r\n");
  198.             inli(s,ro,160,1);
  199.             if(stricmp(s,"/ES")==0) optoo=1;
  200.             if(stricmp(s,"/ABT")==0) optoo=2;
  201.             if(optoo) break;
  202.             fprintf(ff,"%s\n",s);
  203.             k++;
  204.          }
  205.          if(optoo==2) {
  206.             fclose(ff);
  207.             unlink(fn);
  208.             pl("Auto-Message aborted.");
  209.          }
  210.          if(optoo==1) {
  211.            outstr("Saving...");
  212.            strcpy(author,thisuser.name);
  213.            fprintf(ff,"%c%d",3,color2);
  214.            for(k=0;k<79;k++)
  215.              fputc(196, ff);
  216.            fprintf(ff,"\n");
  217.            fclose(ff);
  218.            sprintf(s,"copy %stemp.msg %snew_auto.ans > nul",syscfg.gfilesdir,
  219.                         syscfg.gfilesdir);
  220.            system(s);
  221.            for(k=0;k<9;k++) {
  222.              outstr("<");
  223.              backspace();
  224.              backspace();
  225.            }
  226.            prt(2,"Creating non-ansi auto-message...");
  227.            sprintf(s,"%snew_auto.ans",syscfg.gfilesdir);
  228.            ff=fopen(s,"r");
  229.            sprintf(s,"%snew_auto.msg",syscfg.gfilesdir);
  230.            gg=fopen(s,"w");
  231.            while(!feof(ff)) {
  232.              s[0]=fgetc(ff);
  233.              if(s[0]=='─') fputc('-',gg);
  234.              else if(s[0]==3) fgetc(ff);
  235.              else fputc(s[0],gg);
  236.            }
  237.            fclose(ff);
  238.            fclose(gg);
  239.            for(k=0;k<33;k++) {
  240.              outstr("<");
  241.              backspace();
  242.              backspace();
  243.            }
  244.            prt(2,"Rewriting status...");
  245.            gg=fopen("AUTOMSG.CNT","w");
  246.            fprintf(gg,"%d\n%d\n%d\n%d\n%d\n%d\n%s",AMSGLINES,anonysl,
  247.                 color1,color2,lock,anony,author);
  248.            fclose(gg);
  249.            for(k=0;k<19;k++) {
  250.              outstr("<");
  251.              backspace();
  252.              backspace();
  253.            }
  254.            prt(2,"Auto-Message saved.");
  255.          }
  256.          break;
  257.       }
  258.    }
  259. }
  260.  
  261.  
  262. ============================================================================
  263. Step 3: Change calls to old auto-message to new auto-message
  264. ============================================================================
  265.  
  266. In LILO.C, in void logon(), look for this:
  267. ┌───────────────────────┐
  268. │  if (ss!=NULL)        │
  269. │    farfree(ss);       │
  270. │  nl();                │
  271. │  if (live_user)       │
  272. │    read_automessage();│
  273. └───────────────────────┘
  274. Change
  275.     read_automessage();
  276. to
  277.     printfile("NEW_AUTO");  /* This is for Version 1.1 -- Change this line! */
  278.  
  279. in BBS.C, in void mainmenu() look for
  280. ┌─────────┐
  281. │case 'A':│
  282. └─────────┘
  283. And change the:
  284.    write_automessage();
  285. to
  286.    newam();
  287.  
  288. ============================================================================
  289. Step 4: Add auto-message editor (Be sure and do this step!)
  290. ============================================================================
  291.  
  292. First, go to BBS.C, and in void mainmenu() look for this:
  293. ┌─────────────────────────────────────────────────────┐
  294. │     for (i=0; i<MAX_SUBS; i++)                      │
  295. │        if (strcmp(usub[i].keys,s)==0)               │
  296. │          cursub=i;                                  │
  297. │/**************************************************/ │
  298. │  if (so()) {                                        │
  299. └─────────────────────────────────────────────────────┘
  300. And add this RIGHT after the last line:
  301.  
  302.     if (strcmp(s, "AEDIT")==0)
  303.       aedit();
  304.  
  305. ============================================================================
  306. Step 5: Add the Auto-Message setup editor
  307. ============================================================================
  308.  
  309. Open MISCCMD.C.  Add the following function to the end:
  310.  
  311. void aedit()
  312. {
  313.   FILE *gg;
  314.   char choice,color1,color2,lock,anony,author[81],s[81];
  315.   int anonysl,lines;
  316.  
  317.   gg=fopen("AUTOMSG.CNT","r+");
  318.   if(gg==NULL) {
  319.     prt(1,"\r\nAuto message status file not found. Creating with defaults.\r\n"
  320. );
  321.     gg=fopen("AUTOMSG.CNT","w+");
  322.     fprintf(gg,"20\n255\n7\n1\n0\n0\n ");
  323.     fseek(gg,0,SEEK_SET);
  324.   }
  325.   lines=atoi(fgets(s,80,gg));
  326.   anonysl=atoi(fgets(s,80,gg));
  327.   color1=atoi(fgets(s,80,gg));
  328.   color2=atoi(fgets(s,80,gg));
  329.   lock=atoi(fgets(s,80,gg));
  330.   anony=atoi(fgets(s,80,gg));
  331.   fgets(author,80,gg);
  332.   fclose(gg);
  333.  
  334.   for(;;) {
  335.     nl();
  336.     itoa(lines,s,10);
  337.     npr("   %c7Auto-Message Stats:\r\n",3);
  338.     npr("1> Max. Lines: %s\r\n",lines ? s : "Unlimited");
  339.     npr("2> Anony Security Level: %d\r\n",anonysl);
  340.     npr("3> Color #1: %c%dColor %c0(#%d)\r\n",3,color1,3,color1);
  341.     npr("4> Color #2: %c%dColor %c0(#%d)\r\n",3,color2,3,color2);
  342.     npr("5> Locked? %s\r\n", lock ? "Yes" : "No");
  343.     pl("Q> Quit+Save");
  344.     pl("X> Quit Without Saving");
  345.     npr("Auto-Message Written by: %s\r\n", author);
  346.     outstr("Choose: [1-5,Q,X] ? ");
  347.     choice=getkey();
  348.     npr("%c",choice);
  349.     if(isalpha(choice)) choice=toupper(choice);
  350.     if(choice=='Q' || choice=='X' || (choice>='1' && choice<='5')) {
  351.       nl();
  352.       switch(choice) {
  353.         case '1':
  354.           outstr("Enter new max lines (0 for unlimited): ");
  355.           mpl(3);
  356.           input(s,3);
  357.           lines=atoi(s);
  358.           npr("Maximum lines now: %s.", lines ? s : "Unlimited");
  359.           break;
  360.         case '2':
  361.           outstr("Enter new security level to write anonymous: ");
  362.           mpl(3);
  363.           input(s,3);
  364.           anonysl=atoi(s);
  365.           npr("New Anony SL: %d.",anonysl);
  366.           break;
  367.         case '3':
  368.           outstr("Enter new color for Color #1: ");
  369.           mpl(1);
  370.           s[0]=getkey();
  371.           npr("%c",s[0]);
  372.           nl();
  373.           if(s[0]>='0' && s[0]<='7')
  374.             color1=(s[0]-'0');
  375.           else
  376.             pl("Not a valid color (range: 0-7)");
  377.           break;
  378.         case '4':
  379.           outstr("Enter new color for Color #2: ");
  380.           mpl(1);
  381.           s[0]=getkey();
  382.           npr("%c",s[0]);
  383.           nl();
  384.           if(s[0]>='0' && s[0]<='7')
  385.             color2=(s[0]-'0');
  386.           else
  387.             pl("Not a valid color (range: 0-7)");
  388.           break;
  389.         case '5':
  390.           lock = (!lock);
  391.           npr("Auto-Message now %s.", lock ? "locked" : "unlocked");
  392.           break;
  393.         case 'X':
  394.           return;
  395.         case 'Q':
  396.           gg=fopen("AUTOMSG.CNT","w");
  397.           fprintf(gg,"%d\n%d\n%d\n%d\n%d\n%d\n%s",lines,anonysl,
  398.                   color1,color2,lock,anony,author);
  399.           fclose(gg);
  400.           return;
  401.           break;
  402.       }
  403.     }
  404.   }
  405. }
  406. ============================================================================
  407. Step 6: Function prototypes
  408. ============================================================================
  409.  
  410. Either use MAKE FCNS, or  edit FCNS.H. Delete  the  void read_automessage(),
  411. void  write_automessage1(), and  void   write_automessage(). Then  add  void
  412. newam(void); to the end of the functions in MISCCMD.C (I suggest using  MAKE
  413. FCNS, though :-)).
  414.  
  415.  
  416.  
  417.